/*
 * author      : 吴中勤
 * date        : 2019/3/18
 * description : TODO
 */

package org.wzq.learn.threadpool;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.wzq.learn.AppRuntimeEnv;

public class AppRuntimeEnvThread extends Thread {
    private static final Logger logger = LoggerFactory.getLogger(AppRuntimeEnvThread.class);

    public AppRuntimeEnvThread(Runnable target) {
        super(target);
    }

    public void run() {
        if (logger.isInfoEnabled()) logger.info("AppRuntimeEnvThread::run start");
        super.run();
        if (logger.isInfoEnabled()) logger.info("AppRuntimeEnvThread::run end");
    }

    private AppRuntimeEnv appRuntimeEnv;

    public AppRuntimeEnv getAppRuntimeEnv() {
        return appRuntimeEnv;
    }

    public void clean() {
        this.appRuntimeEnv = null;
    }

    public void setLocal(String json) {
        if (logger.isInfoEnabled()) logger.info("after setLocal, json=" + json);
        this.appRuntimeEnv = AppRuntimeEnv.fromJson(json);
    }
}
